package com.zdlee.netty.server15.serialize.impl;

import com.alibaba.fastjson.JSON;
import com.zdlee.netty.server15.serialize.Serializer;
import com.zdlee.netty.server15.serialize.SerializerAlogrithm;

/**
 * @author zdlee
 * @description: ${DESCRIPTION}
 * @create 2018-11-29 13:35
 */
public class JSONSerializer implements Serializer {

    @Override
    public byte getSerializerAlgorithm() {
        return SerializerAlogrithm.JSON;
    }

    @Override
    public byte[] serialize(Object object) {
        return JSON.toJSONBytes(object);
    }

    @Override
    public <T> T deserialize(Class<T> clazz, byte[] bytes) {
        return JSON.parseObject(bytes,clazz);
    }


}
